# Definition for a binary tree node.
class TreeNode(object):
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution(object):

    # def mirror(self,left,right):
    #     if left == None and right ==None:
    #         return True
    #     elif (left==None and right!=None or left!=None and right==None):
    #         return False
    #     else:
    #         if right.val != left.val:
    #             return False
    #         if self.mirror(left.left,right.right) and self.mirror(left.right,right.left):
    #             return True
    #         else:
    #             return False

    def mirror(self,left,right):
        if left==None or right ==None:
            return left==right
        if left.val != right.val:
            return False
        return self.mirror(left.left,right.right) and self.mirror(left.right,right.left)




    def isSymmetric(self, root):
        """
        :type root: TreeNode
        :rtype: bool
        """
        if not root:
            return True
        return self.mirror(root.left,root.right)



m1 = TreeNode(1)
m1.left = TreeNode(2)
m1.right = TreeNode(2)
m1.left.left = TreeNode(2)

s = Solution()

t = s.isSymmetric(m1)
print(t)
